package cn.sc.summer.admin.enums;

import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 枚举类型：admin服务实例状态枚举类
 *
 * @author a-xin
 * @date 10:38
 */
@Getter
@AllArgsConstructor
public enum InstanceStatusEnum {

    DOWN("DOWN", "健康检查没通过"),
    OFFLINE("OFFLINE", "服务下线"),
    UP("UP", "服务上线"),
    UNKNOWN("UNKNOWN", "服务未知异常"),
    ;

    private final String type;
    private final String desc;

    public static InstanceStatusEnum getByType(String type) {
        if (StrUtil.isBlank(type)) {
            return null;
        }
        for (InstanceStatusEnum enums : InstanceStatusEnum.values()) {
            if (enums.type.equals(type)) {
                return enums;
            }
        }
        return null;
    }

}
